﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Numbers;
using Microsoft.Silverlight.Testing;

namespace t_Numbers
{
    [TestClass]
    public class t_Alpha
    {
        [TestMethod]
        public void TestCreation()
        {
            Alpha te = new Alpha();

            Assert.AreEqual(1.0, te.alpha_b, "should init b-tagging eff to zero");
            Assert.AreEqual(1.0, te.alpha_c, "Should init c-tagging eff to zero");
            Assert.AreEqual(1.0, te.alpha_l, "Should init the -ltagging eff to zero");
        }

        [TestMethod]
        public void TestSetting()
        {
            Alpha te = new Alpha();

            te.alpha_b = 0.1;
            te.alpha_c = 0.2;
            te.alpha_l = 0.3;

            Assert.AreEqual(0.1, te.alpha_b, "should init b-tagging eff to zero");
            Assert.AreEqual(0.2, te.alpha_c, "Should init c-tagging eff to zero");
            Assert.AreEqual(0.3, te.alpha_l, "Should init the -ltagging eff to zero");

            te.alpha_b = te.alpha_c = te.alpha_l = 20.0;
            Assert.AreEqual(20.0, te.alpha_b, "should init b-tagging eff to zero");
            Assert.AreEqual(20.0, te.alpha_c, "Should init c-tagging eff to zero");
            Assert.AreEqual(20.0, te.alpha_l, "Should init the -ltagging eff to zero");
        }

        [TestMethod]
        public void TestChangedEvent()
        {
            Alpha te = new Alpha();
            int count = 0;
            string lastPropName = "";
            te.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((o, args) =>
            {
                count += 1;
                lastPropName = args.PropertyName;
            });

            te.alpha_b = 100;
            Assert.AreEqual(1, count, "alpha_b didn't fire a changed event");
            Assert.AreEqual("alpha_b", lastPropName, "The last changed property name isn't right either!");

            te.alpha_c = 100;
            Assert.AreEqual(2, count, "alpha_b didn't fire a changed event");
            Assert.AreEqual("alpha_c", lastPropName, "The last changed property name isn't right either!");
            te.alpha_l = 100;
            Assert.AreEqual(3, count, "alpha_b didn't fire a changed event");
            Assert.AreEqual("alpha_l", lastPropName, "The last changed property name isn't right either!");
        }
    }
}